/**
 * Copyright (C), 2020-2030, Unionman Tech. Co., Ltd.
 * All rights reserved.
 *
 * @file    hi_fmp4muxer.h
 * @brief   hi fmp4muxer functions declaration
 * @author  rifan.qiu
 * @date    2020/11/17
 */

#ifndef __HI_FMP4MUXER_H__
#define __HI_FMP4MUXER_H__

#include "hi_appcomm.h"

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

typedef enum tagFMP4MUXER_VIDEO_TYPE_E
{
    FMP4MUXER_VIDEO_TYPE_H264 = 0,
    FMP4MUXER_VIDEO_TYPE_H265,
    FMP4MUXER_VIDEO_TYPE_BUTT
} FMP4MUXER_VIDEO_TYPE_E;

typedef enum tagFMP4MUXER_AUDIO_TYPE_E
{
    FMP4MUXER_AUDIO_TYPE_G711A = 0,
    FMP4MUXER_AUDIO_TYPE_BUTT
} FMP4MUXER_AUDIO_TYPE_E;

typedef enum tagFMP4MUXER_TRACK_TYPE_E
{
    FMP4MUXER_TRACK_TYPE_AUDIO = 0,
    FMP4MUXER_TRACK_TYPE_VIDEO,
    FMP4MUXER_TRACK_TYPE_BUTT
} FMP4MUXER_TRACK_TYPE_E;

typedef struct tagFMP4MUXER_VIDEO_ENCODER_ATTR_S
{
    FMP4MUXER_VIDEO_TYPE_E enType;
    HI_S32 s32Width;
    HI_S32 s32Height;
} FMP4MUXER_VIDEO_ENCODER_ATTR_S;

typedef struct tagFMP4MUXER_AUDIO_ENCODER_ATTR_S
{
    HI_S32 s32ChannelCount;
    HI_S32 s32BitsPerSample;
    HI_S32 s32SampleRate;
} FMP4MUXER_AUDIO_ENCODER_ATTR_S;

/**
 * @brief    init fmp4 muxer
 * @return 0 success,non-zero error code.
 * @exception    None
 */
HI_S32 FMP4MUXER_Init(HI_VOID);

/**
 * @brief    deinit fmp4 muxer
 * @return 0 success,non-zero error code.
 * @exception    None
 */
HI_S32 FMP4MUXER_DeInit(HI_VOID);

/**
 * @brief    create fmp4 muxer file
 * @param[in] filename : fmp4 file name
 * @param[in] pstVideoAttr : video encoder attr
 * @param[in] pstAudioAttr : audio encoder attr
 * @param[out] hFMP4Muxer : fmp4muxer handle
 * @return 0 success,non-zero error code.
 * @exception    None
 */
HI_S32 FMP4MUXER_Create(const HI_CHAR* filename, FMP4MUXER_VIDEO_ENCODER_ATTR_S *pstVideoAttr,
                    FMP4MUXER_AUDIO_ENCODER_ATTR_S *pstAudioAttr, HI_HANDLE *hFMP4Muxer);

/**
 * @brief    close fmp4 muxer file
 * @param[in] hFMP4Muxer : fmp4muxer handle
 * @return 0 success,non-zero error code.
 * @exception    None
 */
HI_S32 FMP4MUXER_Close(HI_HANDLE hFMP4Muxer);

/**
 * @brief    write data to fmp4 muxer file
 * @param[in] hFMP4Muxer : fmp4muxer handle
 * @param[in] enTrackType : tarack type
 * @param[in] data : data to write
 * @param[in] bytes : data size
 * @param[in] pts : pts
 * @param[in] dts : dts
 * @param[in] flags : I frame flag
 * @return 0 success,non-zero error code.
 * @exception    None
 */
HI_S32 FMP4MUXER_Write(HI_HANDLE hFMP4Muxer, FMP4MUXER_TRACK_TYPE_E enTrackType,
                    const HI_VOID* data, HI_U32 bytes, HI_S64 pts, HI_S64 dts, HI_S32 flags);


#ifdef __cplusplus
}
#endif

#endif // __HI_FMP4MUXER_H__

